#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char tmp[111] = {0};
char out[111] = {0};
char stack[111] = {0};
int pos = 0;
int outp = 0;

char top()
{
    return stack[pos];
}

char top_fix()
{
    switch (stack[pos])
    {
    case '(':
        return ')';
    case '[':
        return ']';
    case '{':
        return '}';
    default:
        return 0;
    }
}

void push(char x)
{
    stack[++pos] = x;
}

void pop()
{
    --pos;
}

void append(char x)
{
    out[outp++] = x;
}

int main()
{
    scanf("%s", tmp);
    for (int i = 0; i < strlen(tmp); ++i)
    {
        switch (tmp[i])
        {
        case '(':
        case '[':
        case '{':
            push(tmp[i]);
            append(tmp[i]);
            break;
        case ')':
            if (top() == '(')
            {
                pop();
                append(tmp[i]);
            }
            else
            {
                while (top() != '(' && pos > 0)
                {
                    append(top_fix());
                    pop();
                }
            }
            break;
        case ']':
            if (top() == ']')
            {
                pop();
                append(tmp[i]);
            }
            else
            {
                while (top() != ']' && pos > 0)
                {
                    append(top_fix());
                    pop();
                }
            }
            break;
        case '}':
            if (top() == '}')
            {
                pop();
                append(tmp[i]);
            }
            else
            {
                while (top() != '}' && pos > 0)
                {
                    append(top_fix());
                    pop();
                }
            }
            break;
        default:
            break;
        }
    }
    while (pos > 0)
    {
        append(top_fix());
        pop();
    }
    printf("%s\n", out);
    return 0;
}